package com.steak.zk.config;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.BoundedExponentialBackoffRetry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 刘牌
 * @Title:
 * @date 2022/3/1910:18
 */
@Configuration
public class CuratorConfiguration {

    @Bean
    public CuratorFramework curatorFramework(){
        CuratorFramework curatorFramework = CuratorFrameworkFactory.builder()
                .connectString("116.198.160.39:2181")
                .sessionTimeoutMs(60000)
                .connectionTimeoutMs(60000)
                .retryPolicy(new BoundedExponentialBackoffRetry(1000,1000,3000))
                .build();
        curatorFramework.start();
        return curatorFramework;
    }
}
